/**
 * Created By wifi_uncle on 2019/11/6
 */

import API from '../api'
import { Toast } from 'mint-ui';
const getPrefix = function (_this) {
  return _this.utilHelper.apiUrl
}
const Log = function (info, flag = true) {
  if (flag) {
    window.console.log(info)
  }
}
const SUCCESS_CODE = '1'
export default {
  /**
   * 获取推荐人列表
   * @param premisesId
   * @param _this
   * @returns {PromiseLike<any> | Promise<any> | *}
   */
  getRecommendList (premisesId, _this) {
    let url = getPrefix(_this) + API.RECOMMEND.RECOMMEND_LIST
    let body = {}
    body.params = {
      id: premisesId
    }
    return _this.$http.post(url, body).then(rsp => { // 无同步
      const data = rsp.body
      if (data && data.result === SUCCESS_CODE) {
        return Promise.resolve(data.resData.list)
      } else {
        Toast('获取楼盘推荐人失败')
        return Promise.reject(data)
      }
    }, e => {
      Toast('获取楼盘推荐人失败')
      return Promise.reject(e)
    })
  },
}
